var status = -1;
var selectionLog = [];
var items = [1592019, 1582027, 1582017, 1552128, 1552110, 1542108, 1532144, 1522138, 1492231, 1482216, 1472261, 1462239, 1452252, 1442268, 1432214, 1422184, 1412177, 1402251, 1382259, 1372222, 1362135, 1342101, 1332274, 1322250, 1312199, 1302333, 1292017, 1282016, 1272016, 1262017, 1252093, 1242120, 1242116, 1232109, 1222109, 1213017, 1212115];

function start() {
    action(1, 0, 0)
}

function action(e, c, b) {
    if (im.getServerName().equals("BMS单机") && im.getServerName().equals("BMS至尊体验服") && !im.getServerName().equals("BMS至尊")) {
        im.playerMessage(1, " 使用环境异常，请还原服务端配置。");
        im.dispose();
        return
    }
    if (status == 0 && e == 0) {
        im.dispose();
        return
    }(e == 1) ? status++ : status--;
    selectionLog[status] = b;
    var a = -1;
    if (status <= a++) {
        im.dispose()
    } else {
        if (status === a++) {
            for (var a = 0; a < items.length; a++) {
                if (im.haveItem(items[a])) {
                    var d = "想要兑换哪一件武器？\r\n#b";
                    for (var a = 0; a < items.length; a++) {
                        d += "#L" + a + "##i" + items[a] + "##z" + items[a] + "##l\r\n"
                    }
                    im.askMenu(d);
                    return
                }
            }
            im.sendOk("你的背包里没有任意一件#b埃苏莱布斯武器#k，无法进行变换。");
            im.dispose()
        } else {
            if (status === a++) {
                im.dispose();
                var f = im.getItemId();
                im.gainItem(f, -1);
                for (var a = 0; a < items.length; a++) {
                    if (im.haveItem(items[a])) {
                        im.gainItem(items[a], -1);
                        im.gainItem(items[b], 1);
                        return
                    }
                }
            }
        }
    }
};